package com.example.qasys.utils;


import okhttp3.*;
import org.springframework.stereotype.Service;

import java.io.IOException;
import java.util.concurrent.TimeUnit;

@Service
public class OkHttpUtil {

    private  OkHttpClient httpClient = new OkHttpClient().newBuilder().connectTimeout(60000, TimeUnit.MILLISECONDS)
            .readTimeout(60000, TimeUnit.MILLISECONDS)
            .build();

    public String doGet(Request request) throws IOException {

        try (Response response = httpClient.newCall(request).execute()) {
            return response.body().string();
        }
    }

    public  String doPost(Request request) throws IOException {
        try (Response response = httpClient.newCall(request).execute()) {
            return response.body().string();
        }
    }



}
